<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:t="http://myfaces.apache.org/tomahawk">
<head>
<title>Alert</title>
</head>
<body>
<ui:composition template="/template.xhtml">
	<ui:define name="navigation">
		<ui:include src="navigation.xhtml" />
	</ui:define>
	
	<ui:define name="heading">
		<h:outputText value="#{alertBean.alertFor} Alert" />
	</ui:define>

	<ui:define name="body">
		<h:form id="form">
			<h:panelGrid id="grid" columns="2">
				<h:outputText value="Stock Code/Symbol" />
				<h:inputText id="stockCode" value="#{alertBean.stockCode}" required="true" />

				<h:messages id="messages" errorClass="error" infoClass="success" />
				<h:outputText value="" />

				<h:outputText value="Transaction Type" />
				<h:selectOneListbox value="#{alertBean.trxType}" required="true">
					<f:selectItem itemLabel="Buy" itemValue="Buy" />
					<f:selectItem itemLabel="Sell" itemValue="Sell" />
					<f:selectItem itemLabel="Virtual Buy" itemValue="Virtual Buy" />
					<f:selectItem itemLabel="Virtual Sell" itemValue="Virtual Sell" />
				</h:selectOneListbox>

				<h:outputText value="Event Date" />
				<t:inputDate type="date" popupCalendar="true" value="#{alertBean.eventDate}" required="true" />

				<h:outputText value="Opportunity Type" />
				<h:selectOneListbox value="#{alertBean.opportunityType}" required="true">
					<f:selectItem itemLabel="Short-Term" itemValue="Short-Term" />
					<f:selectItem itemLabel="Intermediate-Term Bullish" itemValue="Intermediate-Term Bullish" />
					<f:selectItem itemLabel="Long-Term" itemValue="Long-Term" />
				</h:selectOneListbox>

				<h:outputText value="Event Price" />
				<h:inputText id="eventPrice" value="#{alertBean.eventPrice}" required="true" onblur="this.form['form:sltp'].value=round(parseInt(this.value) - (parseInt(this.value) * .05));">
					<f:convertNumber type="number" />
				</h:inputText>

				<h:outputText value="Target Price" />
				<h:inputText id="targetPrice" value="#{alertBean.targetPrice}" required="true" />

				<h:outputText value="SLTP" />
				<h:inputText id="sltp" value="#{alertBean.sltp}" required="true" />

				<h:outputText value="Event Type" />
				<h:selectOneListbox value="#{alertBean.eventType}" required="true" size="10">
					<f:selectItems value="#{alertBean.eventTypes}" />
				</h:selectOneListbox>

				<h:outputText value="Quantity" />
				<h:inputText id="qty" value="#{alertBean.qty}" required="true" maxlength="5">
					<f:convertNumber type="number" groupingUsed="false" integerOnly="true" />
				</h:inputText>

				<h:outputText value="Active" />
				<h:selectOneListbox value="#{alertBean.isActive}" required="true">
					<f:selectItem itemLabel="Yes" itemValue="Y" />
					<f:selectItem itemLabel="No" itemValue="N" />
				</h:selectOneListbox>

				<h:commandButton value="Save" action="#{alertBean.save}" />
			</h:panelGrid>
		</h:form>
		<script>
			setTimeout("document.getElementById('form:stockCode').focus()", 1000);
		</script>
	</ui:define>
</ui:composition>
</body>
</html>
